package com.example.test.app.main;

import com.example.test.R;
import com.example.test.chapter10.MainChapter10;
import com.example.test.chapter13.MainChapter13;
import com.example.test.chapter14.MainChapter14;
import com.example.test.chapter15.MainChapter15;
import com.example.test.chapter16.MainChapter16;
import com.example.test.chapter8.MainChapter8;
import com.example.test.chapter9.MainChapter9;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ApplicationMain extends Activity implements OnItemClickListener {
	private String[] chapter = new String[] { "Chương 8", "Chương 9",
			"Chương 10", "Chương 13", "Chương 14", "Chương 15", "Chương 16" };
	private int[] idChapter = new int[] { 1, 2, 3, 4, 5, 6, 7 };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_app);
		ListView listView = (ListView) findViewById(R.id.listViewMain);
		listView.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, chapter));
		listView.setOnItemClickListener(this);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		switch (idChapter[arg2]) {
		case 1:
			startActivity(new Intent(this, MainChapter8.class));
			break;
		case 2:
			startActivity(new Intent(this, MainChapter9.class));
			break;
		case 3:
			startActivity(new Intent(this, MainChapter10.class));
			break;
		case 4:
			startActivity(new Intent(this, MainChapter13.class));
			break;
		case 5:
			startActivity(new Intent(this, MainChapter14.class));
			break;
		case 6:
			startActivity(new Intent(this, MainChapter15.class));
			break;
		case 7:
			startActivity(new Intent(this, MainChapter16.class));
			break;
		default:
			break;
		}

	}
}
